package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.MemberIdAndRoleIdListVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.SubMemberIdRoleIdVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberAssignedPageQueryVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.MemberAssignedSearchConditionVO;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.MemberAbilityAssignedMemberQueryVO;
import com.ssy.lingxi.member.merchant.service.web.IMemberAbilityAssignedService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员能力-会员管理-待分配会员相关接口
 * @author whm
 * @version 2.0.0
 * @date 2022-03-29
 **/
@RestController
@RequestMapping("/member/ability/assigned")
public class MemberAbilityAssignedController {

    @Resource
    private IMemberAbilityAssignedService memberAbilityAssignedService;

    /**
     * 列表查询页面中各个下拉选择框的内容
     *
     * @param headers Http头部信息
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems", method = RequestMethod.GET)
    public Wrapper<MemberAssignedSearchConditionVO> getPageCondition(@RequestHeader HttpHeaders headers) {
        return memberAbilityAssignedService.getPageCondition(headers);
    }

    /**
     * 分页、模糊查询会员
     *
     * @param headers Http头部信息
     * @param queryVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<MemberAssignedPageQueryVO>> pageMembers(@RequestHeader HttpHeaders headers, @Valid MemberAbilityAssignedMemberQueryVO queryVO) {
        return memberAbilityAssignedService.pageMembers(headers, queryVO);
    }

    /**
     * 操作用户领取会员
     *
     * @param headers Http头部信息
     * @param subMemberList  接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/bind", method = RequestMethod.POST)
    public Wrapper<Void> pageMembers(@RequestHeader HttpHeaders headers, @RequestBody @Valid List<SubMemberIdRoleIdVO> subMemberList) {
        return memberAbilityAssignedService.bindOperator(headers, subMemberList);
    }
}
